<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    
    <h:head>
        <title>vBox-Edit User</title>
        <style type="text/css">
                .ui-widget {
                    font-family: Tahoma;
                    font-size: 11px;
                }
        </style>
    </h:head>  
    <h:body>
        <h:outputStylesheet library="css" name="component.css"/>
        <f:metadata>
            <f:viewParam id="userId" name="userId" value="#{userBean.userId}" required="true" requiredMessage="Người dùng không tồn tại"/>
            <f:event type="preRenderView" listener="#{userBean.preRenderEditView()}" />
        </f:metadata>
        <h:form id="mainForm">
            <p:panel style="height:500px" rendered="#{userBean.user != null}">
                <p:messages id="msgs"/>
                <p:toolbar style="margin-bottom: 10px; margin-top: 10px;">
                    <p:toolbarGroup align="left">  
                        <p:commandButton value="Update" actionListener="#{userBean.updateAction()}" update=":mainForm"/>
                        <p:commandButton type="reset" value="Reset"/>
                    </p:toolbarGroup>
                </p:toolbar>
                
                <h:panelGrid styleClass="panelGrid" columnClasses="ui-state-default labelCol, ui-widget-content, ui-state-default labelCol, ui-widget-content" 
                             columns="2" cellpadding="5" width="100%">
                    <h:outputLabel for="username" style="display: inline; float: right; padding-right: 5px;" value="Username *" />  
                    <p:inputText value="#{userBean.user.username}" id="username" required="true" label="Username" maxlength="50"
                                 requiredMessage="The Username is required"/>
                    
                    <h:outputLabel for="activated" style="display: inline; float: right; padding-right: 5px;" value="Active" />  
                    <p:selectBooleanCheckbox value="#{userBean.user.activated}" id="activated" label="Active"/>
                    
                    <h:outputLabel style="display: inline; float: right; padding-right: 5px;" value="Role" />
                    <p:pickList value="#{userBean.roleModels}" var="role" itemLabel="#{role.name}" 
                                itemValue="#{role}" converter="roleConverter"
                                showSourceControls="true" showTargetControls="true">
                        <f:facet name="sourceCaption">Role List</f:facet>  
                        <f:facet name="targetCaption">Selected Role</f:facet>
                    </p:pickList>
                </h:panelGrid>
            </p:panel>
        </h:form>  
    </h:body>  
</html>
